import { estypes } from "sdk-es8";

export type InfoResult = {
  type: string;
  version: string;
  status?: string;
  lucene?: string;
  spaceUsed?: estypes.ByteSize;
  nodes?: estypes.ClusterStatsClusterNodes;
};

export type KUpdateResponse = {
  _id: string;
  _source: unknown;
  _version: number;
};

export type KStatsIndexesCollection = {
  documentCount: number;
  name: string;
  size: estypes.ByteSize;
};

export type KStatsIndex = {
  collections: KStatsIndexesCollection[];
  name: string;
  size: estypes.ByteSize;
};

export type KStatsIndexes = {
  [key: string]: KStatsIndex;
};

export type KStats = {
  indexes: KStatsIndex[];
  size: estypes.ByteSize;
};

export type KRequestBody<T> = T & {
  _kuzzle_info?: {
    author: string;
    createdAt: number;
    updatedAt: number | null;
    updater: string | null;
  };
};

export interface JSONObject {
  [key: string]: any;
}

export type KImportError = {
  _id: string;
  status: string;
  _source?: JSONObject;
  error?: {
    reason: string;
    type: string;
  };
};

export type KRequestParams = {
  refresh?: boolean | "wait_for";
  timeout?: string;
  userId?: string;
  injectKuzzleMeta?: boolean;
  limits?: boolean;
  source?: boolean;
};
